/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Entity;

import java.io.Serializable;
import java.util.Date;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.validation.constraints.NotNull;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * @author adama
 */
@Entity
@Table(name = "relationvideoplaylist")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Relationvideoplaylist.findAll", query = "SELECT r FROM Relationvideoplaylist r"),
    @NamedQuery(name = "Relationvideoplaylist.findByIdRelationVideoPlaylist", query = "SELECT r FROM Relationvideoplaylist r WHERE r.relationvideoplaylistPK.idRelationVideoPlaylist = :idRelationVideoPlaylist"),
    @NamedQuery(name = "Relationvideoplaylist.findByDate", query = "SELECT r FROM Relationvideoplaylist r WHERE r.date = :date"),
    @NamedQuery(name = "Relationvideoplaylist.findByIdVideo", query = "SELECT r FROM Relationvideoplaylist r WHERE r.relationvideoplaylistPK.idVideo = :idVideo"),
    @NamedQuery(name = "Relationvideoplaylist.findByIdPlaylist", query = "SELECT r FROM Relationvideoplaylist r WHERE r.relationvideoplaylistPK.idPlaylist = :idPlaylist")})
public class Relationvideoplaylist implements Serializable {
    private static final long serialVersionUID = 1L;
    @EmbeddedId
    protected RelationvideoplaylistPK relationvideoplaylistPK;
    @Basic(optional = false)
    @NotNull
    @Column(name = "Date")
    @Temporal(TemporalType.TIMESTAMP)
    private Date date;
    @JoinColumn(name = "idPlaylist", referencedColumnName = "idPlaylist", insertable = false, updatable = false)
    @ManyToOne(optional = false)
    private Playlist playlist;
    @JoinColumn(name = "idVideo", referencedColumnName = "idVideo", insertable = false, updatable = false)
    @ManyToOne(optional = false)
    private Video video;

    public Relationvideoplaylist() {
    }

    public Relationvideoplaylist(RelationvideoplaylistPK relationvideoplaylistPK) {
        this.relationvideoplaylistPK = relationvideoplaylistPK;
    }

    public Relationvideoplaylist(RelationvideoplaylistPK relationvideoplaylistPK, Date date) {
        this.relationvideoplaylistPK = relationvideoplaylistPK;
        this.date = date;
    }

    public Relationvideoplaylist(int idRelationVideoPlaylist, int idVideo, int idPlaylist) {
        this.relationvideoplaylistPK = new RelationvideoplaylistPK(idRelationVideoPlaylist, idVideo, idPlaylist);
    }

    public RelationvideoplaylistPK getRelationvideoplaylistPK() {
        return relationvideoplaylistPK;
    }

    public void setRelationvideoplaylistPK(RelationvideoplaylistPK relationvideoplaylistPK) {
        this.relationvideoplaylistPK = relationvideoplaylistPK;
    }

    public Date getDate() {
        return date;
    }

    public void setDate(Date date) {
        this.date = date;
    }

    public Playlist getPlaylist() {
        return playlist;
    }

    public void setPlaylist(Playlist playlist) {
        this.playlist = playlist;
    }

    public Video getVideo() {
        return video;
    }

    public void setVideo(Video video) {
        this.video = video;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (relationvideoplaylistPK != null ? relationvideoplaylistPK.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Relationvideoplaylist)) {
            return false;
        }
        Relationvideoplaylist other = (Relationvideoplaylist) object;
        if ((this.relationvideoplaylistPK == null && other.relationvideoplaylistPK != null) || (this.relationvideoplaylistPK != null && !this.relationvideoplaylistPK.equals(other.relationvideoplaylistPK))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "Entity.Relationvideoplaylist[ relationvideoplaylistPK=" + relationvideoplaylistPK + " ]";
    }
    
}
